package com.platform.pay.controller;

import com.platform.common.config.Global;
import com.platform.common.log.SystemLog;
import com.platform.common.page.Page;
import com.platform.pay.model.Alipay;
import com.platform.pay.service.AlipayService;
import com.platform.upms.model.UpmsUser;
import com.platform.upms.model.json.Tip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping(value = "/pay/alipay")
public class AlipayController {

    @Autowired
    private AlipayService alipayService;

    /**
     * 查询列表，带分页的查询
     * @param modelMap
     * @param alipay
     * @param alipayPage
     * @return
     */
    @RequestMapping("/list")
    @SystemLog(description = "支付列表")
    public String list(ModelMap modelMap,Alipay alipay,Page<Alipay> alipayPage){
        Page<Alipay> alipayList = alipayService.findByPage(alipayPage, alipay);
        modelMap.addAttribute("alipayList",alipayList);
        return "/pay/alipay/list.jsp";
    }

    @RequestMapping("/add")
    @SystemLog(description = "支付宝收账号添加")
    public String add(){ return "/pay/alipay/add.jsp";}

    @RequestMapping("/saveData")
    @ResponseBody
    @SystemLog(description = "支付宝收账添加")
    public Tip saveData(Alipay alipay, HttpSession session){
       UpmsUser upmsUser= (UpmsUser) session.getAttribute(Global.UPMSUSER);
        Integer orgId = upmsUser.getOrgId();
        alipay.setType("1");//停车场收费
//        alipay.setReceiveId();//具体的是哪个停车场
        return  new Tip();
    }
}
